package com.urbainski.componentes.validators
{
	import mx.validators.StringValidator;

	public class MyURLValidator extends StringValidator
	{
		private var chracters:Array;
		private var urlRegExp:RegExp;
		
		private var _valid:Boolean = false;
		
		public function MyURLValidator()
		{
			super();
			urlRegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/g;
		}
		
		public function get valid():Boolean
		{
			return _valid;
		}
		
		public function set valid(value:Boolean):void
		{
			_valid = value;
		}
		
		override protected function doValidation(value:Object):Array {
			
			var results:Array = new Array();
			results = super.doValidation(value);
			
			
			if(results.length > 0) { 
				return results; 
			}
			
			if(value != null){
				
				valid = urlRegExp.test(String(value));
				
			}
			
			return results;
		}
			
	}
}